<template>
  <view class="launch">
    <video
      :src="videoUrl"
      style="width: 100%; height: 100%"
      autoplay
      :controls="false"
      :enable-progress-gesture="false"
      @ended="handleEnded"
    ></video>
  </view>
</template>

<script setup>
import { onLoad } from "@dcloudio/uni-app";
import { ref } from "vue";
import { useStore } from "vuex";

const store = useStore();

const videoUrl = ref(
  "https://image.zkodoo.cc/25/03/13/806bfd50522142069a1763347836418d.mp4"
);

function handleEnded() {
  uni.setStorageSync("isLaunch", true);
  if (store.state.user.currentRoleId == 2) {
    uni.reLaunch({
      url: "/pages/supplier/statistics",
    });
  } else if (store.state.user.currentRoleId == 3) {
    uni.reLaunch({
      url: "/pages/agenter/statistics",
    });
  } else {
    uni.reLaunch({
      url: "/pages/index/index",
    });
  }
}

onLoad(async (qeury) => {
  if (qeury.isGlobal) {
    store.state.isFromGlobal = true;
  }
});
</script>

<style lang="scss" scoped>
.launch {
  height: 100%;
}
</style>
